<template>
  <div class="common-layout">
    <el-container>
      <el-aside width="180px">
        <Layout />
      </el-aside>
      <el-container>
        <el-header>
          <Header />
        </el-header>
        <el-main>
          <div>
            <el-table :data="tableData" stripe style="width: 100%">
              <el-table-column prop="date" label="修改日期" width="180" />
              <el-table-column prop="name" label="文档名称" width="180" />
              <el-table-column fixed="right" label="操作" width="120">
                <template #default="scope">
                  <el-button link type="primary" size="small" @click.prevent="editRow(scope.row)">
                    编辑
                  </el-button>
                </template>
              </el-table-column> </el-table>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
  <el-dialog v-model="optionVisible" title="文档编辑" width="800">
    <editForm :fileTitle="fileTitle"></editForm>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="optionVisible = false">Cancel</el-button>
        <el-button type="primary" @click="saveFile">
          确定
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { ref } from "vue"
import editForm from './components/editForm.vue'

const tableData = ref([
  {
    date: '2016-05-03',
    name: '修磨油压系统油箱修理',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: '修磨油压系统油箱修理',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: '修磨油压系统油箱修理',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: '修磨油压系统油箱修理',
    address: 'No. 189, Grove St, Los Angeles',
  },
])
const optionVisible = ref(false)
const fileTitle = ref('')
for (let index = 0; index < 15; index++) {
  const element = {
    date: '2016-05-03',
    name: '修磨油压系统油箱修理',
    address: 'No. 189, Grove St, Los Angeles',
  }
  tableData.value.push(element)
}
const editRow = (row) => {
  console.log(row)
  fileTitle.value = row.name
  optionVisible.value = true
}
const saveFile = ()=>{

}
</script>

<style lang="less" scoped>
.common-layout {
  height: 100%;

  .el-container {
    height: 100%;
  }

  .el-header {
    padding: 0;
  }
}
</style>
